#!/bin/bash
# This is used by the unit test harness (specifically skip_js_exec).
# You likely want to use skip_js_eval or run_js_file instead of this.


# run_js [--no-unhandled-exception-stack] sk-to-js-file [args...]

set -e -o pipefail

if [ "$1" = "--no-unhandled-exception-stack" ]
then
  DEBUG_OPT=$1
  shift
else
  DEBUG_OPT=
fi

JS_FILE=$1/sk.js
shift

RUN_JS=$(dirname "$0")/run_js_file
if [ "$WATCH" == "1" ]; then
  RUN_JS=$(dirname "$0")/run_reactive_js_file
fi

${RUN_JS} $DEBUG_OPT $JS_FILE "$@"
